import java.util.Scanner;

public class demo06 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] arr=new int[n+1];
        for (int i = 1; i <= n; i++) {
            arr[i]=sc.nextInt();
        }
        int[] dp=new int[n+1];
        dp[0]=1;
        for (int i = 1; i <= n; i++) {
            int max=Integer.MIN_VALUE;
            int min=Integer.MAX_VALUE;
            for (int j = i; j > 0; j--) {
                max=Math.max(max,arr[j]);
                min=Math.min(min,arr[j]);
                if(max-min==i-j){
                    dp[i]=dp[i]+dp[j-1];
                }
            }
        }
        System.out.println(dp[n]);
    }
}
